# Add subdirectories for each language if desired
string(TOLOWER "$ENV{BUILD_OVIP_SWIG}" swig_target)

if(NOT "${swig_target}" STREQUAL "")
message(DEBUG "build swig = ${swig_target}")
# Include SWIG
if(POLICY CMP0078)
    message("Find CMP0078, set it be NEW")
    cmake_policy(SET CMP0078 NEW)
endif()
if(POLICY CMP0086)
    message("Find CMP0086, set it be NEW")
    cmake_policy(SET CMP0086 NEW)
endif()
if(POLICY CMP0148)
    message("Find CMP0148, set it be NEW")
    cmake_policy(SET CMP0148 NEW)
endif()

find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})

if(${swig_target} STREQUAL "python")
    add_subdirectory(python)
elseif(${swig_target} STREQUAL "java")
    add_subdirectory(java)
elseif(${swig_target} STREQUAL "javascript")
    add_subdirectory(javascript)
elseif(${swig_target} STREQUAL "on")
    add_subdirectory(python)
    add_subdirectory(javascript)
else()
    message(FATAL_ERROR "BUILD_SWIG should be set to python/java/javascript, but it is: ${swig_target}")
endif()
endif()
